package com.itheima.dao;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component("sun")
@Scope("singleton")
public class Sun {
    //创建 Sun 的一个对象
    private static Sun instance = new Sun();

    //让构造函数为 private，这样该类就不会被实例化
    private Sun(){}

    //获取唯一可用的对象
    public static Sun getInstance(){
        return instance;
    }

    public void showMessage(){
        System.out.println("Hello World!");
    }
}
